/* @(#)DecKanGlCanvas.java
** 
** Copyright (C) 2001-2011 by Steven D. Stamps
**
**             Trademarks & Copyrights
** Flywheel Management Science(TM) and FlywheelMS(TM) are exclusive
** trademarks of Steven D. Stamps and may only be used freely for
** the purpose of identifying the unforked version of this software.
** Subsequent forks (if any) may not use these trademarks.  All other
** rights are reserved.
**
** DecKanGL (Decorated Kanban Glyph Language) and TribKn (Tribal Knowledge)
** are also exclusive trademarks of Steven D. Stamps.  These may be used
** freely within the unforked FlywheelMS application and documentation.
** All other rights are reserved.
**
** Trademark information is available at
** <http://www.flywheelms.org/trademarks>
**
** Flywheel Management Science(TM) is a copyrighted body of management
** metaphors, governance processes, and leadership techniques that is
** owned by Steven D. Stamps.  These copyrighted materials may be freely
** used, without alteration, by the community (users and developers)
** surrounding this GPL3-licensed software.  Additional copyright
** information is available at <http://www.flywheelms.org/copyrights>
**
**              GPL3 Software License
** This program is free software: you can use it, redistribute it and/or
** modify it under the terms of the GNU General Public License, version 3,
** as published by the Free Software Foundation. This program is distributed
** in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
** even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
** PURPOSE.  See the GNU General Public License for more details. You should
** have received a copy of the GNU General Public License, in a file named
** COPYING, along with this program.  If you cannot find your copy, see
** <http://www.gnu.org/licenses/gpl-3.0.html>.
*/
package com.fmscorp.deckangl.core;

import java.awt.Color;
import java.util.HashMap;

import javax.swing.ImageIcon;

import com.fmscorp.deckangl.Decorator;

/**
 * @author sstamps
 */
public class Canvas {
	
	private ImageIcon nounStateImageIcon;
	private HashMap<DecoratorCanvasLocation, Decorator> decoratorMap;
	private GlyphDictionary decKanGlGlyphDictionary;
	private Color decoratorBackgroundColor;
	private Color decoratorBackgroundColorMediumAlpha;
	private Color decoratorBackgroundColorLightAlpha;
	private Color nounBackgroundOuterColor;

	public Canvas(
			ImageIcon aNounStateImageIcon,
			 HashMap<DecoratorCanvasLocation, Decorator> aDecoratorMap,
			GlyphDictionary aDecKanGlGlyphDictionary ) {
			this(
					aNounStateImageIcon,
					aDecoratorMap,
					aDecKanGlGlyphDictionary,
					aDecKanGlGlyphDictionary.getDecoratorBackgroundColor(),
					aDecKanGlGlyphDictionary.getDecoratorBackgroundColorMediumAlpha(),
					aDecKanGlGlyphDictionary.getDecoratorBackgroundColorLightAlpha(),
					aDecKanGlGlyphDictionary.getNounBackgroundColor() );
	}

	public Canvas(
			ImageIcon aNounStateImageIcon,
			HashMap<DecoratorCanvasLocation, Decorator> aDecoratorMap,
			GlyphDictionary aDecKanGlGlyphDictionary,
			Color aCanvasDecoratorBackgroundColor,
			Color aCanvasDecoratorBackgroundColorMediumAlpha,
			Color aCanvasDecoratorBackgroundColorLightAlpha,
			Color aCanvasNounBackgroundColor ) {
		this.nounStateImageIcon = aNounStateImageIcon;
		this.decoratorMap = aDecoratorMap;
		this.decKanGlGlyphDictionary = aDecKanGlGlyphDictionary;
		this.decoratorBackgroundColor = aCanvasDecoratorBackgroundColor;
		this.decoratorBackgroundColorMediumAlpha = aCanvasDecoratorBackgroundColorMediumAlpha;
		this.decoratorBackgroundColorLightAlpha = aCanvasDecoratorBackgroundColorLightAlpha;
		this.nounBackgroundOuterColor = aCanvasNounBackgroundColor;
	}

	public int getMarginLeft() {
		return this.decKanGlGlyphDictionary.getMarginCanvasLeft();
	}

	public int getMarginRight() {
		return decKanGlGlyphDictionary.getMarginCanvasRight();
	}

	public int getMarginTop() {
		return decKanGlGlyphDictionary.getMarginCanvasTop();
	}

	public int getMarginBottom() {
		return decKanGlGlyphDictionary.getMarginCanvasBottom();
	}
	
	public int getWidthLeftZone() {
		if (!GlyphDictionary.decoratorsUseZone(
				this.decoratorMap, CanvasZone.LEFT_ZONE)) {
			return 0;
		}
		return decKanGlGlyphDictionary.getWidthLeftZone();
	}
	
	public int getWidthRightZone() {
		if (!GlyphDictionary.decoratorsUseZone(
				this.decoratorMap, CanvasZone.RIGHT_ZONE)) {
			return 0;
		}
		return decKanGlGlyphDictionary.getWidthRightZone();
	}
	
	public int getMarginNounStatusLeft() {
		return decKanGlGlyphDictionary.getMarginNounStatusLeft();
	}
	
	public int getMarginNounStatusRight() {
		return decKanGlGlyphDictionary.getMarginNounStatusRight();
	}
	
	public int getMarginNounStatusTop() {
		return decKanGlGlyphDictionary.getMarginNounStatusTop();
	}
	
	public int getMarginNounStatusBottom() {
		return decKanGlGlyphDictionary.getMarginNounStatusBottom();
	}
	
	public int getWidthNounStatusGlyph() {
		return this.nounStateImageIcon.getIconWidth();
	}
	
	public int getHeightNounStatusGlyph() {
		return this.nounStateImageIcon.getIconHeight();
	}
	
	public int getHeightTopZone() {
		if (!GlyphDictionary.decoratorsUseZone(
				this.decoratorMap, CanvasZone.TOP_ZONE)) {
			return 0;
		}
		return this.decKanGlGlyphDictionary.getHeightTopZone();
	}
	
	public int getHeightBottomZone() {
		if (!GlyphDictionary.decoratorsUseZone(
				this.decoratorMap, CanvasZone.BOTTOM_ZONE)) {
			return 0;
		}
		return this.decKanGlGlyphDictionary.getHeightBottomZone();
	}

	public int getWidth() {
		return 	getMarginLeft() +
				getWidthLeftZone() +
				getMarginNounStatusLeft() +
				getWidthNounStatusGlyph() +
				getMarginNounStatusRight() +
				getWidthRightZone() +
				getMarginRight();
	}

	public int getHeight() {
		return 	getMarginTop() +
				getHeightTopZone() +
				getMarginNounStatusTop() +
				getHeightNounStatusGlyph() +
				getMarginNounStatusBottom() +
				getHeightBottomZone() +
				getMarginBottom();
	}

	int getNounStatusImageCanvasPositionX() {
		return 	getMarginLeft() +
				getWidthLeftZone() +
				getMarginNounStatusLeft();
	}

	int getNounStatusImageCanvasPositionY() {
		return 	getMarginTop() +
				getHeightTopZone() +
				getMarginNounStatusTop();
	}

	public Color getNounBackgroundColor() {
		if (this.nounBackgroundOuterColor == null) {
			this.nounBackgroundOuterColor = decKanGlGlyphDictionary.getNounBackgroundColor();
		}
		return nounBackgroundOuterColor;
	}

	public Color getDecoratorBackgroundColor() {
		if (this.decoratorBackgroundColor == null) {
			this.decoratorBackgroundColor = decKanGlGlyphDictionary.getDecoratorBackgroundColor();
		}
		return decoratorBackgroundColor;
	}

	public Color getDecoratorBackgroundColorMediumAlpha() {
		if (this.decoratorBackgroundColorMediumAlpha == null) {
			this.decoratorBackgroundColorMediumAlpha = decKanGlGlyphDictionary.getDecoratorBackgroundColorMediumAlpha();
		}
		return decoratorBackgroundColorMediumAlpha;
	}

	public Color getDecoratorBackgroundColorLightAlpha() {
		if (this.decoratorBackgroundColorLightAlpha == null) {
			this.decoratorBackgroundColorLightAlpha = decKanGlGlyphDictionary.getDecoratorBackgroundColorLightAlpha();
		}
		return decoratorBackgroundColorLightAlpha;
	}

	public void setColor(Color color) {
		this.decoratorBackgroundColor = color;
	}

	public Color getTransparency() {
		return GlyphDictionary.getCanvasColorTransparent();
	}

}